package midalgorithms.sortandsearch;

import java.util.Arrays;

public class _05SearchRange {
    public static int[] searchRange(int[] nums, int target) {
        if (nums.length == 0){
            return new int[]{-1,-1};
        }
        int left = -1,right = -1;
        for (int i = 0;i < nums.length;i++){
            if (nums[i] == target){
                left = i;
                right = left;
                break;
            }
        }
        if (left == -1){
            return new int[]{-1,-1};
        }
        for (int i = left;i < nums.length;i++){
            if (nums[i] == target){
                right = i;
            }
        }
        if (left == right){
            return new int[]{left,left};
        }

        return new int[]{left,right};
    }
}
